/**
 * 
 */
package br.com.pim.form;

import javax.servlet.ServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

import br.com.pim.model.UsuarioModel;

/**
 * @author douglas.peixoto
 * 
 */
public class LoginForm extends ActionForm {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3558639514603528419L;
	private UsuarioModel usuario = new UsuarioModel();

	@Override
	public ActionErrors validate(ActionMapping mapping, ServletRequest req) {
		ActionErrors erros = new ActionErrors();

		if (this.usuario.getVrLogin() == null|| this.usuario.getVrLogin().length() == 0) {
			erros.add(ActionErrors.GLOBAL_MESSAGE, new ActionMessage(
					"Username preenchido incorretamente"));
		}
		if (this.usuario.getVrSenha() == null|| this.usuario.getVrSenha().length() == 0) {
			erros.add(ActionErrors.GLOBAL_MESSAGE, new ActionMessage(
					"Senha preenchida incorretamente"));
		}
		return erros;
	}

	public UsuarioModel getUsuario() {
		return usuario;
	}

	public void setUsuario(UsuarioModel usuario) {
		this.usuario = usuario;
	}

}
